﻿// Deep Earth is a community project available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warranty – Use at your own risk
// View the project and the latest code at http://DeepEarth.codeplex.com/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace DeepEarth.Client.MapControl
{
    public static class FrameworkElementEx
    {
        public static IObservable<IEvent<ValidationErrorEventArgs>> GetBindingValidationError(this FrameworkElement frameworkElement)
        {
            return Observable.FromEvent<ValidationErrorEventArgs>(frameworkElement, "BindingValidationError");
        }

        public static IObservable<IEvent<RoutedEventArgs>> GetUnloaded(this FrameworkElement frameworkElement)
        {
            return Observable.FromEvent<RoutedEventArgs>(frameworkElement, "Unloaded");
        }

        public static IObservable<IEvent<EventArgs>> GetLayoutUpdated(this FrameworkElement frameworkElement)
        {
            return Observable.FromEvent<EventArgs>(frameworkElement, "LayoutUpdated");
        }

        public static IObservable<IEvent<SizeChangedEventArgs>> GetSizeChanged(this FrameworkElement frameworkElement)
        {
            return Observable.FromEvent<SizeChangedEventArgs>(frameworkElement, "SizeChanged");
        }

        public static IObservable<IEvent<RoutedEventArgs>> GetLoaded(this FrameworkElement frameworkElement)
        {
            return Observable.FromEvent<RoutedEventArgs>(frameworkElement, "Loaded");
        }
    }
}